package cn.tedu.charging.device.controller;

import cn.tedu.charging.common.pojo.query.NearStationsQuery;
import cn.tedu.charging.common.pojo.vo.StationDetailVO;
import cn.tedu.charging.common.pojo.vo.StationInfoVO;
import cn.tedu.charging.common.protocol.JsonResult;
import cn.tedu.charging.device.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 站场、桩、枪控制层
 */
@RestController
public class DeviceController {
    @Autowired
    private DeviceService deviceService;
    // 查询附近的充电站
    @GetMapping("/device/station/near")
    public JsonResult<List<StationInfoVO>> nearStations(NearStationsQuery query){
        List<StationInfoVO> list = deviceService.getNearStations(query);
        return JsonResult.ok(list);
    }

    @GetMapping("/device/station/detail/{stationId}")
    public JsonResult<StationDetailVO> getStationDetail(@PathVariable Integer stationId){
        StationDetailVO stationDetailVO = deviceService.getStationDetail(stationId);
        return JsonResult.ok(stationDetailVO);
    }

    @GetMapping("/device/gun/check")
    public JsonResult<Boolean> checkGun(@RequestParam("gunId") Integer gunId){
        return JsonResult.ok(true);
    }
}
